package Pattern.FactoryPattern.workTest.Work.Program6;

interface CPU{
    void create();
}

interface RAM{
    void create();
}

class PcCPU implements CPU{

    @Override
    public void create() {
        System.out.println("win's CPU");
    }
}

class MacCPU implements CPU{

    @Override
    public void create() {
        System.out.println("mac's CPU");
    }
}

class PcRAM implements RAM{

    @Override
    public void create() {
        System.out.println("win's RAM");
    }
}

class MacRAM implements RAM{

    @Override
    public void create() {
        System.out.println("mac's RAM");
    }
}

interface ComputerFactory{
    CPU produceCPU();
    RAM produceRAM();
}

class PcFactory implements ComputerFactory{

    @Override
    public CPU produceCPU() {
        System.out.println("win's CPU produced!");
        return new PcCPU();
    }

    @Override
    public RAM produceRAM() {
        System.out.println("win's RAM produced!");
        return new PcRAM();
    }
}

class MacFactory implements ComputerFactory{

    @Override
    public CPU produceCPU() {
        System.out.println("mac's CPU produced");
        return new MacCPU();
    }

    @Override
    public RAM produceRAM() {
        System.out.println("mac's RAM produced");
        return new MacRAM();
    }
}

public class Test {
    public static void main(String[] args) {
        ComputerFactory factory;
        CPU cpu;
        RAM ram;
        factory = new PcFactory();
        cpu = factory.produceCPU();
        cpu.create();
        ram = factory.produceRAM();
        ram.create();
        System.out.println();
        factory = new MacFactory();
        cpu = factory.produceCPU();
        cpu.create();
        ram = factory.produceRAM();
        ram.create();
    }
}
